1. Technology Field
The present invention generally relates to a method for identifying valid data, and more particularly, to a method for identifying valid data after a power failure, and a memory storage device and a memory controller using the same.
2. Description of Related Art
Flash memory is broadly applied to various electronic devices thanks to its many advantages, such as data non-volatility, low power consumption, small volume, and non-mechanical structure. Besides, flash memory is adopted by many portable storage devices, such as memory cards and flash drives, as their storage media.
Generally, a flash memory in a memory storage device is divided into a plurality of physical blocks, and these physical blocks are grouped into a data area and a spare area. Physical blocks in the data area are used for storing valid data written by write commands, and physical blocks in the spare area are used for substituting the physical blocks in the data area when the write commands are executed. To be specific, when a memory storage device receives a write command from a host and accordingly is about to write data into a physical block in the data area, the memory storage device selects a physical block from the spare area and writes old valid data in the physical block in the data area and the new data into the physical block selected from the spare area. Besides, the memory storage device links the physical block containing the new data to the data area and erases the physical block originally in the data area and links it to the spare area.
In order to accomplish the operation described above, the memory storage device provides logical blocks to the host to allow the host to access data. To be specific, the memory storage device maintains a logical block-physical block mapping table for recording the mapping relationship between the logical blocks and the physical blocks in the data area. Meanwhile, when the memory storage device executes a write command therefore alternates a physical block in the data area and a physical block in the spare area, the memory storage device updates the logical block-physical block mapping table to make sure that subsequently data can be successfully accessed.
However, in order to increase data writing speed and avoid meaningless data moving operations, after the memory storage device selects the physical block from the spare area and writes the old valid data in the physical block in the data area and the new data into the physical block selected from the spare area, it does not instantly move all the valid data in the physical block in the data area to the physical block selected from the spare area or erase the physical block in the data area, so that a temporary mother-child relationship is maintained between the physical block in the data area and the physical block selected from the spare area. Herein the physical block in the data area is referred to as a mother physical block, and the physical block selected from the spare area is referred to as a child physical block. However, because every time the host writes a data of different quantity, in order to make the writing operations more efficient, a mother physical block may have multiple child physical blocks at the same time (for example, child physical blocks for writing continuous data and child physical blocks for writing data of small quantities). Accordingly, physical pages respectively belonging to different physical blocks may be mapped to the same logical page.
A memory storage device usually maintains a record table to record the latest physical page corresponding to each logical page. However, the record table may be lost or the content thereof may not be updated in time when a power failure occurs. When the power supply is resumed, even though the physical page corresponding to a specific logical page can be determined, in which physical page the latest valid data of the logical page is stored cannot be determined.
Nothing herein should be construed as an admission of knowledge in the prior art of any portion of the present invention. Furthermore, citation or identification of any document in this application is not an admission that such document is available as prior art to the present invention, or that any reference forms a part of the common general knowledge in the art.